import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue'
import About from '../views/About.vue'
import News from '../views/News.vue'
import New from '../views/New.vue'
import Product from '../views/Product.vue'
import Boxs from '../views/Boxs.vue'
import Box from '../views/Box.vue'
import Touch from '../views/Touch.vue'
import Recruits from '../views/Recruits.vue'
import Docs from '../views/Docs.vue'
import Doc from '../views/Doc.vue'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
// import { from } from 'core-js/core/array'

const routes = [
  // 首页路由
  {
    path: '/',
    name: 'home',
    component: Home
  },
  // 关于我们路由
  {
    path: '/about',
    name: 'about',
    component: About
  },
  // 关于我们子页面路由
  {
    path: '/about/history',
    name: 'history',
    component: () => import('../views/about/History.vue')
  },
  {
    path: '/about/team',
    name: 'team',
    component: () => import('../views/about/Team.vue')
  },
  {
    path: '/about/organization',
    name: 'organization',
    component: () => import('../views/about/Organization.vue')
  },
  {
    path: '/about/honors',
    name: 'honors',
    component: () => import('../views/about/Honors.vue')
  },
  // 新闻模块路由(健康咨询)
  {
    path: '/news',
    name: 'news',
    component: News
  },
  {
    path: '/news/:id',
    name: 'new',
    component: New
  },
  // 新闻子页面
  {
    path: '/news/media',
    name: 'media',
    component: () => import('../views/news/Media.vue')
  },
  {
    path: '/news/video',
    name: 'newsVideo',
    component: () => import('../views/news/Video.vue')
  },
  // 联系模块路由(联系我们)
  {
    path: '/touch',
    name: 'touch',
    component: Touch
  },
  // 包厢模块路由
  {
    path: '/boxs',
    name: 'boxs',
    component: Boxs
  },
  {
    path: '/boxs/:id',
    name: 'box',
    component: Box
  },
  // 业务子页面
  {
    path: '/boxs/services',
    name: 'services',
    component: () => import('../views/boxs/Services.vue')
  },
  {
    path: '/boxs/projects',
    name: 'projects',
    component: () => import('../views/boxs/Projects.vue')
  },
  // 招聘模块路由(加入我们)
  {
    path: '/recruits',
    name: 'recruits',
    component: Recruits
  },
  // 招聘子页面
  {
    path: '/recruits/campus',
    name: 'campus',
    component: () => import('../views/recruits/Campus.vue')
  },
  {
    path: '/recruits/social',
    name: 'social',
    component: () => import('../views/recruits/Social.vue')
  },
  {
    path: '/recruits/intern',
    name: 'intern',
    component: () => import('../views/recruits/Intern.vue')
  },
  // 产品模块路由
  {
    path: '/product',
    name: 'product',
    component: Product
  },
  // 企业文化子页面
  {
    path: '/product/social',
    name: 'socialResp',
    component: () => import('../views/product/Social.vue')
  },
  {
    path: '/product/innovation',
    name: 'innovation',
    component: () => import('../views/product/Innovation.vue')
  },
  // 文档模块路由
  {
    path: '/docs',
    name: 'docs',
    component: Docs
  },
  {
    path: '/docs/:id',
    name: 'doc',
    component: Doc
  },
  // 法律页面
  {
    path: '/legal/privacy',
    name: 'privacy',
    component: () => import('../views/legal/Privacy.vue')
  },
  {
    path: '/legal/terms',
    name: 'terms',
    component: () => import('../views/legal/Terms.vue')
  },
  // 网站地图
  {
    path: '/sitemap',
    name: 'sitemap',
    component: () => import('../views/Sitemap.vue')
  },
  // 搜索页面
  {
    path: '/search',
    name: 'search',
    component: () => import('../views/Search.vue')
  },
  // 404页面
  {
    path: '/:pathMatch(.*)*',
    name: 'notFound',
    component: () => import('../views/NotFound.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

// 钩子函数实现加载功能
// 前置钩子
router.beforeEach((to,from,next)=>{
  NProgress.start();
  next()
})
// 后置钩子
router.afterEach((to,from,next)=>{
  NProgress.done();
  // next()
})

export default router
